{#
This file is part of EC-CUBE

Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.

http://www.ec-cube.co.jp/

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#}
{% extends 'default_frame.twig' %}

{% set menus = ['setting', 'shop', 'shop_delivery'] %}

{% block title %}ショップ設定{% endblock %}
{% block sub_title %}配送先管理{% endblock %}

{% form_theme form 'Form/bootstrap_3_horizontal_layout.html.twig' %}

{% block javascript %}
<script>
$(function(){
    $("#set_fee_all").on("click", function() {
        var fee = $("#{{ form.free_all.vars.id }}").val();
        $("input[name$='[fee]']").val(fee);
    });
});
</script>
{% endblock javascript %}

{% block main %}
<div class="row" id="aside_wrap">
    <form role="form" class="form-horizontal" name="form1" id="form1" method="post" action="">
        {{ form_widget(form._token) }}
            <div id="detail_wrap" class="col-md-9">
                <div id="delivery_info_box" class="box">
                    <div id="delivery_info_box__header" class="box-header">
                        <h3 class="box-title">基本情報</h3>
                    </div><!-- /.box-header -->
                    <div id="delivery_info_box__body" class="box-body">

                        {{ form_row(form.name) }}
                        {{ form_row(form.service_name) }}
                        {{ form_row(form.confirm_url) }}
                        {{ form_row(form.product_type, { attr : { class : 'form-inline' } }) }}

                        <div class="extra-form">
                            {% for f in form.getIterator %}
                                {% if f.vars.name matches '[^plg*]' %}
                                    {{ form_row(f) }}
                                {% endif %}
                            {% endfor %}
                        </div>

                    </div><!-- /.box-body -->
                </div><!-- /.box -->

                <div id="payments_box" class="box">
                    <div id="payments_box__header" class="box-header">
                        <h3 class="box-title">支払方法設定</h3>
                    </div><!-- /.box-header -->
                    <div id="payments_box__body" class="box-body">
                        {{ form_widget(form.payments) }}
                        {{ form_errors(form.payments) }}
                    </div>
                </div>

                <div id="delivery_times_box" class="box accordion clearfix">
                    <div id="delivery_times_box__toggle" class="box-header toggle">
                        <h3 class="box-title">お届け時間設定<svg class="cb cb-angle-down icon_down"> <use xlink:href="#cb-angle-down" /></svg></h3>
                    </div><!-- /.box-header -->
                    <div id="delivery_times_box__body" class="box-body accpanel">
                        {% for child in form.delivery_times %}
                            {% if loop.first %}
                                <div id="delivery_times_box__body_inner" class="form-group">
                            {% endif %}

                            <label class="col-sm-2 control-label">
                                お届け時間{{ loop.index }}
                            </label>
                            <div id="delivery_times_box__delivery_times--{{ loop.index0 }}" class="col-sm-4">
                                {{ form_widget(child) }}
                            </div>

                            {% if loop.last == true %}
                                </div>
                            {% endif %}
                        {% endfor %}
                    </div>
                </div>

                <div id="delivery_pref_box" class="box accordion">
                    <div id="delivery_pref_box__header" class="box-header">
                        <h3 class="box-title">都道府県別送料設定</h3>
                    </div>
                    <div id="delivery_pref_box__body" class="box-body">
                        <div id="delivery_pref_box__free_all" class="form-inline fees_area">
                            全国一律送料&nbsp; {{ form_widget(form.free_all) }}
                            <a class="btn btn-normal btn-default btn-sm" href="javascript:;" id="set_fee_all">各都道府県に反映</a>
                        </div>
                    </div><!-- /.box-header -->
                    <div id="delivery_pref_box__body_toggle" class="box-body toggle active" style="position:relative;">
                        <h3 class="box-title">都道府県ごとに設定する<svg class="cb cb-angle-down icon_down"> <use xlink:href="#cb-angle-down" /></svg></h3>
                    </div>
                    <div id="delivery_pref_box__body_inner" class="box-body accpanel" style="display: block;">
                        {% for child in form.delivery_fees %}
                            {% if loop.first %}
                                <div id="delivery_pref_box__item" class="form-group">
                            {% endif %}

                                <label id="delivery_pref_box__header_delivery_fee--{{ child.vars.name }}" class="col-sm-2 control-label">
                                    {{ child.vars.data.pref|default('') }}
                                </label>
                                <div id="delivery_pref_box__delivery_fee--{{ child.vars.name }}" class="col-sm-4 fees_area">
                                    {{ form_widget(child) }}
                                </div>

                            {% if loop.last == true %}
                                </div>
                            {% endif %}
                        {% endfor %}
                    </div>
                </div>

                <div id="detail__back_button" class="row hidden-xs hidden-sm">
                    <div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3 text-center btn_area">
                        <p><a href="{{ url('admin_setting_shop_delivery') }}">一覧に戻る</a></p>
                    </div>
                </div>

            </div><!-- /.col -->
            <div class="col-md-3" id="aside_column">
                <div id="common_box" class="col_inner">
                    <div id="common_button_box" class="box no-header">
                        <div id="common_button_box__body" class="box-body">
                            <div id="common_button_box__insert_button" class="row text-center">
                                <div class="col-sm-6 col-sm-offset-3 col-md-12 col-md-offset-0">
                                    <button class="btn btn-primary btn-block btn-lg" type="submit">登録</button>
                                </div>
                            </div>
                        </div><!-- /.box-body -->
                    </div><!-- /.box -->
                    <div id="common_shop_note_box" class="box">
                        <div id="common_shop_note_box__header" class="box-header">
                            <h3 class="box-title">ショップ用メモ欄</h3>
                        </div><!-- /.box-header -->
                        <div id="common_shop_note_box__body" class="box-body">
                            {{ form_widget(form.description) }}
                        </div>
                    </div>
                </div>
            </div><!-- /.col -->
    </form>
</div>

{% endblock %}